<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
    var a = "12";
    var b = 3 ;
    var c = "12px";
    var d ;
    console.log(a-b);// console.log(Number(a)-b);
    //先将两边的值转为Number再计算
    // 特殊+运算例外
    console.log(c-b);//console.log(Number(c)-b);
    //NaN和其他的值做运算，结果还是为NaN
    console.log(a-d); //console.log(Number(a)-(Number)b);
    </script>
</body>
</html>